#ifndef MYRXTX_H
#define MYRXTX_H 1

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "sem182/sem182.h"

/* debug-mode toggle macro:
 * - set to 0 to disable debug output
 * - set to 1 to enable debug output */
#define DEBUG 0
/* debug-mode bytecount divisor macro
 *  debug-mode prints sent and received packets. You can control the 
 *  amount of output by modifying DEBUG_BC_DIVISOR. Only after each 
 *  DEBUG_BC_DIVISOR's sent/received packet the debug-mode will trigger
 *  output.*/
#define DEBUG_BC_DIVISOR 100

#define SEMKEY_R 1110258010
#define SEMKEY_W 1110258006
#define SHMKEY 1110258010

/* custom error return macro for myrxtx-error handling */
#define MYRXTX_ERROR -1

/* Semaphore/SHM-permissions in umask-fashion */
#define PERMMASK_SEM 0660
#define PERMMASK_SHM 0660

/* global var that stores the filename of the calling program */
extern char * thisfname;

/* protos */
extern int handle_params(int argc, char * argv[]);
extern int init_sem(key_t key, int initval);
extern int init_shm(key_t key, size_t size);
extern void cleanup(int * semid_r, int * semid_w, int * shmid, int * shmptr);
extern void print_usage();
extern void print_error_eno(int eno);
extern void print_error_msg(char * msg);

#endif
